package com.example.finalsystem.Controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.example.finalsystem.Service.GoodsService;
import com.example.finalsystem.Service.InListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class InController {
    @Autowired
    InListService InListService;
    @Autowired
    GoodsService goodsService;

//    只需要进货数量信息

    @ResponseBody
    @PostMapping("/in/addInList")
    public String addInList(@RequestParam String importName,@RequestParam Integer importNumber)
    {

        return InListService.addInList(importName,importNumber);
    }

    //    仓库管理员 确认 出货单 state 设置为已确认   只更改进货数量 其他保持一致
    @ResponseBody
    @PostMapping("/in/fixInList")
    public String fixInList(@RequestParam String inListId,@RequestParam Integer importNumber,@RequestParam String importName,@RequestParam String state)
    {
        return InListService.fixInList(inListId,importName,state,importNumber);
    }

    @ResponseBody
    @PostMapping("/in/deleteInList")
    public String deleteInList(@RequestParam String inListId)
    {
        return InListService.deleteInList(inListId);
    }

    @ResponseBody
    @PostMapping("/in/getInList")
    public String getInList(@RequestParam String InListId)
    {
        return JSON.toJSONString( InListService.getInList(InListId) );
    }

    @ResponseBody
    @PostMapping("/in/getAllInList")
    public String getAllInList()
    {
        return JSONArray.toJSONString(InListService.getAllInList());
    }


}
